<template>
    <transition name="view">
  <div class="lg-viewer" v-if="isView">
    <div class="bg"></div>
    <div class="viewer-photo">
        <img :src="baseUrl+photos[nowNumber]"/>
    </div>
    <div class="swith sw-left" @click="changeNumber(0)" v-show="nowNumber>0">
        <img src="@/assets/images/向左.png">
    </div>
    <div class="swith sw-right" @click="changeNumber(1)" v-show="nowNumber<photos.length-1">
        <img src="@/assets/images/向右.png">
    </div>
  </div>
</transition>
</template>

<script>
import {baseUrl} from '@/utils/env'
export default {
    data(){
        return{
            baseUrl
        }
    },
    props:{
        photos:{
            default:[]
        },
        nowNumber:{
            type:Number,
            default:0
        },
        isView:{
            default:false,
        }
    },
    methods:{
        changeNumber(e){
            this.$emit('viewSwitch',e)
        }
    }
}
</script>

<style lang="less" scoped>
@import url(/src/styles/commons.less);
.view{
    //入场
    &-enter{
        &-from{
            opacity: 0;
        }
        &-active{
            transition: @tr;
        }
        &-to{
            opacity: 1;
        }
    }
    //出场
    &-leave{
        &-from{
            opacity: 1;
        }
        &-active{
            transition: @tr;
        }
        &-to{
            opacity: 0;
        }
    }
}


.lg-viewer{
    position: fixed;
    left:0;
    top:0;
    width: 100%;
    height: 100%;

    .bg{
        position: absolute;
        top: 0;
        left: 0;
        background: rgba(255,255,255,0.8);
        height: 100%;
        width: 100%;
        backdrop-filter: blur(15px);
    }
    .viewer-photo{
        position: absolute;
        padding: 82px 454px 0px 96px;
        padding-right: 360px;
        box-sizing: border-box;
        width:100%;
        height: 100%;
        overflow-y: auto;
        display: flex;
        justify-content: center;
        align-items: center;
        img{
            max-width: 100%;
        }
    }
    .swith{
        width: 56px;
        height: 56px;
        border-radius: 50%;
        background: @gray-3;
        color: @gray-10;
        position: absolute;
        margin: auto;
        top: 0;
        bottom: 0;
        display: flex;
        justify-content: center;
        align-items: center;
        opacity: 0.5;
        transition: @tr;
        cursor: pointer;
        img{
            width: 30px;
            height: 30px;
        }
        &:hover{
            opacity: 1;
        }
    }
    .sw-left{
        left:20px
    }
    .sw-right{
        right: 380px;
    }
}
</style>